
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/10/2012 18:15:51
-- Generated from EDMX file: C:\Yliu's Folder\Projects\360gu\Things\Things.Bar\Models\BarModels.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Codematic];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[NoticeSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NoticeSet];
GO
IF OBJECT_ID(N'[dbo].[NoticeTypeSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NoticeTypeSet];
GO
IF OBJECT_ID(N'[dbo].[NoticeReplySet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NoticeReplySet];
GO
IF OBJECT_ID(N'[dbo].[HotNoticeSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[HotNoticeSet];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'NoticeSet'
CREATE TABLE [dbo].[NoticeSet] (
    [Id] uniqueidentifier  NOT NULL,
    [Title] nvarchar(max)  NOT NULL,
    [Author] nvarchar(max)  NOT NULL,
    [CreatedTime] datetime  NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [IsAllowReply] bit  NOT NULL,
    [TypeId] uniqueidentifier  NOT NULL,
    [Description] nvarchar(max)  NOT NULL,
    [ImgUrl] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'NoticeTypeSet'
CREATE TABLE [dbo].[NoticeTypeSet] (
    [Id] uniqueidentifier  NOT NULL,
    [Caption] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'NoticeReplySet'
CREATE TABLE [dbo].[NoticeReplySet] (
    [Id] uniqueidentifier  NOT NULL,
    [Replyer] nvarchar(max)  NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [ReplyTime] datetime  NOT NULL,
    [NoticeId] uniqueidentifier  NOT NULL
);
GO

-- Creating table 'HotNoticeSet'
CREATE TABLE [dbo].[HotNoticeSet] (
    [Id] uniqueidentifier  NOT NULL,
    [OrderIndex] int  NOT NULL,
    [NoticeId] uniqueidentifier  NOT NULL,
    [Title] nvarchar(max)  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'NoticeSet'
ALTER TABLE [dbo].[NoticeSet]
ADD CONSTRAINT [PK_NoticeSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'NoticeTypeSet'
ALTER TABLE [dbo].[NoticeTypeSet]
ADD CONSTRAINT [PK_NoticeTypeSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'NoticeReplySet'
ALTER TABLE [dbo].[NoticeReplySet]
ADD CONSTRAINT [PK_NoticeReplySet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'HotNoticeSet'
ALTER TABLE [dbo].[HotNoticeSet]
ADD CONSTRAINT [PK_HotNoticeSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------